<!--
	作者：offline
	时间：2019-03-01
	描述：动态窗口 //默认就只会存在一个取消按钮
-->

<template>
    <div>
        <el-dialog :title="title" v-dialogDrag :width="width" :cancelComponent="cancelComponent" :before-close="handleClose" v-bind="$attrs" v-on="$listeners" :close-on-click-modal="false" :close-on-press-escape="false">
            <dynamicForm :formList="formList" :cancelComponent='cancelComponent' v-on="$listeners" v-bind="$attrs"></dynamicForm>
            <span slot="footer" class="dialog-footer">
                <el-button  @click="cancel">取消</el-button>
                <slot></slot>
            </span>
        </el-dialog>
    </div>
</template>

<script>
    import dynamicForm from '@/components/dynamicForm/dynamicForm.vue';

    export default {
        data(){
            return{
                cancelComponent:false
            }
        },
        props:{
            title:{
                type:String,
                required:true
            },
            width:{
                type:String,
                required:true
            },
            formList:{
                type:Array,
                required:true
            }
        },
        inheritAttrs:true,
        methods:{
            handleClose(done){
                this.cancelComponent = true;
            },
            cancel(){
                this.cancelComponent = true;
            }
        },
        mounted(){
        },
        components:{
            dynamicForm
        }
    }
</script>